library(ggplot2)
library(rnaturalearth)
library(rnaturalearthhires)  # Install from GitHub if not already
library(ggspatial)
# Optional: install if needed
# devtools::install_github("ropensci/rnaturalearthhires")
# Download high-resolution provinces and states
provinces_states <- ne_download(
type = "admin_1_states_provinces",
category = "cultural",
scale = 10,
returnclass = "sf"
)
# Filter to Canada and US states in the Bay of Fundy region
provinces_states <- provinces_states[provinces_states$admin %in% c("Canada", "United States of America"), ]
# Download high-res coastline
coastline <- ne_download(
type = "coastline",
category = "physical",
scale = 10,
returnclass = "sf"
)
# Define bounding box for Bay of Fundy region
bbox <- st_as_sfc(st_bbox(c(xmin = -68.5, xmax = -63, ymin = 43.8, ymax = 46.5), crs = 4326))
# Crop layers to bbox
provinces_cropped <- st_intersection(provinces_states, bbox)
coastline_cropped <- st_intersection(coastline, bbox)
# Plot map
ggplot() +
geom_sf(data = provinces_cropped, fill = "grey90", color = "black", size = 0.3) +
geom_sf(data = coastline_cropped, color = "black", size = 0.2) +
coord_sf(xlim = c(-68.5, -63), ylim = c(43.8, 46.5), expand = FALSE) +
annotation_scale(location = "bl", width_hint = 0.2) +
annotation_north_arrow(location = "bl", which_north = "true") +
theme_minimal() +
theme(
panel.grid.major = element_line(color = "grey80", size = 0.2),
axis.title = element_blank()
)
# Load required packages
library(sf)
library(ggplot2)
library(rnaturalearth)
library(rnaturalearthhires)  # Install from GitHub if not already
library(ggspatial)
# Optional: install if needed
# devtools::install_github("ropensci/rnaturalearthhires")
# Download high-resolution provinces and states
provinces_states <- ne_download(
type = "admin_1_states_provinces",
category = "cultural",
scale = 10,
returnclass = "sf"
)
# Filter to Canada and US states in the Bay of Fundy region
provinces_states <- provinces_states[provinces_states$admin %in% c("Canada", "United States of America"), ]
# Download high-res coastline
coastline <- ne_download(
type = "coastline",
category = "physical",
scale = 10,
returnclass = "sf"
)
# Define bounding box for Bay of Fundy region
bbox <- st_as_sfc(st_bbox(c(xmin = -68.5, xmax = -63, ymin = 43.8, ymax = 46.5), crs = 4326))
# Crop layers to bbox
provinces_cropped <- st_intersection(provinces_states, bbox)
coastline_cropped <- st_intersection(coastline, bbox)
# Plot map
ggplot() +
geom_sf(data = provinces_cropped, fill = "grey90", color = "black", size = 0.3) +
geom_sf(data = coastline_cropped, color = "black", size = 0.2) +
coord_sf(xlim = c(-67.5, -66), ylim = c(44.4, 45.3), expand = FALSE) +
annotation_scale(location = "bl", width_hint = 0.2) +
annotation_north_arrow(location = "bl", which_north = "true") +
theme_minimal() +
theme(
panel.grid.major = element_line(color = "grey80", size = 0.2),
axis.title = element_blank()
)
# Load required packages
library(sf)
library(ggplot2)
library(rnaturalearth)
library(rnaturalearthhires)  # Install from GitHub if not already installed
library(ggspatial)
# Optional: install if needed
# devtools::install_github("ropensci/rnaturalearthhires")
# Download high-resolution provinces and states
provinces_states <- ne_download(
type = "admin_1_states_provinces",
category = "cultural",
scale = 10,
returnclass = "sf"
)
# Filter to Canada and US states in the Bay of Fundy region
provinces_states <- provinces_states[provinces_states$admin %in% c("Canada", "United States of America"), ]
# Download high-res coastline
coastline <- ne_download(
type = "coastline",
category = "physical",
scale = 10,
returnclass = "sf"
)
# Define bounding box for Bay of Fundy region
bbox <- st_as_sfc(st_bbox(c(xmin = -68.5, xmax = -63, ymin = 43.8, ymax = 46.5), crs = 4326))
# Crop layers to bbox
provinces_cropped <- st_intersection(provinces_states, bbox)
coastline_cropped <- st_intersection(coastline, bbox)
# Plot map
ggplot() +
geom_sf(data = provinces_cropped, fill = "grey90", color = "black", size = 0.3) +
geom_sf(data = coastline_cropped, color = "black", size = 0.2) +
coord_sf(xlim = c(-68.5, -63), ylim = c(43.8, 46.5), expand = FALSE) +
annotation_scale(location = "bl", width_hint = 0.2) +
annotation_north_arrow(location = "bl", which_north = "true") +
theme_minimal() +
theme(
panel.grid.major = element_line(color = "grey80", size = 0.2),
axis.title = element_blank()
)
# Load required packages
library(sf)
library(ggplot2)
library(rnaturalearth)
library(rnaturalearthhires)  # Install from GitHub if not already installed
library(ggspatial)
# Optional: install if needed
# devtools::install_github("ropensci/rnaturalearthhires")
# Download high-resolution provinces and states
provinces_states <- ne_download(
type = "admin_1_states_provinces",
category = "cultural",
scale = 10,
returnclass = "sf"
)
# Filter to Canada and US states in the Bay of Fundy region
provinces_states <- provinces_states[provinces_states$admin %in% c("Canada", "United States of America"), ]
# Download high-res coastline
coastline <- ne_download(
type = "coastline",
category = "physical",
scale = 10,
returnclass = "sf"
)
# Define bounding box for Bay of Fundy region
bbox <- st_as_sfc(st_bbox(c(xmin = -68.5, xmax = -63, ymin = 43.8, ymax = 46.5), crs = 4326))
# Crop layers to bbox
provinces_cropped <- st_intersection(provinces_states, bbox)
coastline_cropped <- st_intersection(coastline, bbox)
# Plot map
ggplot() +
geom_sf(data = provinces_cropped, fill = "grey90", color = "black", size = 0.3) +
geom_sf(data = coastline_cropped, color = "black", size = 0.2) +
coord_sf(xlim = c(-67.6, -66.0), ylim = c(44.5, 45.2), expand = FALSE) +
annotation_scale(location = "bl", width_hint = 0.2) +
annotation_north_arrow(location = "bl", which_north = "true") +
theme_minimal() +
theme(
panel.grid.major = element_line(color = "grey80", size = 0.2),
axis.title = element_blank()
)
ggplot() +
geom_sf(data = provinces_cropped, fill = "grey90", color = "black", size = 0.3) +
geom_sf(data = coastline_cropped, color = "black", size = 0.2) +
coord_sf(xlim = c(-67.6, -66.0), ylim = c(44.5, 45.3), expand = FALSE) +
annotation_scale(location = "bl", width_hint = 0.2) +
annotation_north_arrow(location = "bl", which_north = "true") +
theme_minimal() +
theme(
panel.grid.major = element_line(color = "grey80", size = 0.2),
axis.title = element_blank()
)
ggplot() +
geom_sf(data = provinces_cropped, fill = "grey90", color = "black", size = 0.3) +
geom_sf(data = coastline_cropped, color = "black", size = 0.2) +
coord_sf(xlim = c(-67.6, -66.0), ylim = c(44.5, 45.3), expand = FALSE) +
annotation_scale(location = "bl", width_hint = 0.2) +
annotation_north_arrow(location = "bl", which_north = "true") +
theme_minimal() +
theme(
panel.grid.major = element_line(color = "grey80", linewidth = 0.2),
axis.title = element_blank()
)
install.packages(c("diffobj", "globals", "httpuv", "miniUI", "recipes", "sparsevctrs", "tinytex"))
library(lme4)
confint.merMod()
?confint.merMod()
library(performance)
??tjur
?prcomp
prcomp
library(MASS)
princomp()
?princomp
install.packages(c("bayestestR", "cli", "insight", "pbkrtest", "pkgdown", "prodlim", "RcppArmadillo", "scales"))
install.packages(c("emmeans", "leafem", "parameters", "reformulas", "systemfonts", "textshaping", "utf8"))
install.packages("emmeans")
install.packages(c("labelled", "parallelly"))
install.packages(c("data.table", "datawizard", "future", "generics", "globals", "Rmpfr", "s2", "terra", "tmap", "zip"))
?gam
library(MASS)
?gam
??gam
library(mgcv)
install.packages(c("Rmpfr", "zip"))
install.packages(c("doBy", "sf"))
# Load libraries
library(MASS)      # For glm.nb
library(emmeans)   # For post hoc-style comparisons
# Example data
df <- data.frame(
count = c(10, 12, 9, 30, 28, 35, 5, 4, 6),
group = factor(rep(c("A", "B", "C"), each = 3))
)
# Fit negative binomial model
nb_model <- glm.nb(count ~ group, data = df)
# Estimated marginal means
emm <- emmeans(nb_model, ~ group)
# Pairwise comparisons with Tukey adjustment
pairs(emm, adjust = "tukey")
nb_model
install.packages(c("bayestestR", "insight", "parameters", "performance", "RcppArmadillo", "recipes", "rsconnect"))
install.packages(c("curl", "data.table", "effectsize", "gh", "openssl", "performance", "pkgbuild", "pkgdown", "s2", "sparsevctrs"))
install.packages(c("haven", "promises", "terra"))
install.packages(c("curl", "future", "future.apply", "parallelly", "spacesXYZ", "terra", "tibble", "utf8", "vegan"))
install.packages("ggeffects")
install.packages(c("data.table", "Deriv", "evaluate", "packrat", "patchwork", "plotly", "rsconnect"))
install.packages("curl")
library(car)
?crPlots
install.packages(c("permute", "rsconnect", "shiny"))
install.packages(c("permute", "rsconnect", "shiny"))
install.packages(c("bayestestR", "doBy", "insight", "permute", "rsconnect", "shiny"))
install.packages(c("bayestestR", "doBy", "ggstats", "insight", "permute", "Rcpp", "RcppArmadillo", "rsconnect", "shiny"))
install.packages(c("bayestestR", "commonmark", "cowplot", "doBy", "ggstats", "insight", "permute", "pillar", "Rcpp", "RcppArmadillo", "rsconnect", "shiny"))
install.packages("parameters")
install.packages(c("data.table", "emmeans", "httr2", "performance", "purrr", "rprojroot", "waldo"))
install.packages(c("datawizard", "GGally", "pbkrtest"))
install.packages(c("GGally", "httr2", "pbkrtest", "Rmpfr", "terra"))
install.packages(c("parallelly", "renv", "tmaptools"))
install.packages(c("broom", "parallelly", "pixmap", "renv", "rnaturalearth", "tmaptools"))
install.packages(c("effects", "future", "ggformula", "mosaic", "mosaicCore", "pROC"))
install.packages(c("checkmate", "glmmTMB", "insight", "PKI", "xfun"))
install.packages(c("afex", "checkmate", "crosstalk", "curl", "evaluate", "GGally", "ggeffects", "ggridges", "ggspatial", "glmmTMB", "hardhat", "insight", "later", "lmeSplines", "parameters", "patchwork", "PKI", "RcppArmadillo", "rprojroot", "xfun", "XML", "xml2"))
install.packages(c("bayestestR", "boot", "cols4all", "emmeans", "evaluate", "insight", "later", "leafem", "lmeSplines", "Matrix", "parameters", "performance", "rsconnect", "rvest", "survey", "usethis"))
install.packages(c("bayestestR", "boot", "cols4all", "emmeans", "evaluate", "gargle", "ggExtra", "googlesheets4", "insight", "later", "leafem", "leaflet", "lmeSplines", "Matrix", "parameters", "performance", "ragg", "RcppArmadillo", "roxygen2", "rsconnect", "rvest", "snowflakeauth", "survey", "textshaping", "TH.data", "usethis"))
install.packages(c("dbplyr", "googledrive", "latticeExtra", "parameters", "RcppArmadillo", "stringr", "tmap"))
install.packages(c("credentials", "dtplyr", "ggplot2", "logger", "magrittr", "parameters", "tmap"))
install.packages("broom")
install.packages(c("ggstats", "labelled", "pillar"))
install.packages(c("progressr", "RcppArmadillo", "vroom"))
install.packages(c("colorspace", "pkgload"))
install.packages(c("forcats", "rmarkdown", "terra"))
install.packages(c("devtools", "ggformula", "Hmisc", "openssl", "performance", "rmarkdown", "systemfonts", "terra"))
install.packages(c("devtools", "ggformula", "ggiraph", "Hmisc", "performance", "systemfonts", "vegan"))
install.packages(c("datawizard", "glmmTMB", "rversions", "textshaping", "units", "vegan"))
install.packages(c("igraph", "TMB"))
install.packages(c("progressr", "TMB"))
install.packages("progressr")
install.packages(c("hms", "progressr", "timeDate"))
install.packages(c("labelled", "multcomp", "promises"))
install.packages("tidyverse")
library(tidyverse)
foo <- (1, 3, sqrt(7))
foo <- c(1, 3, sqrt(7))
foo^2
bar <- c("a", "canada", 7)
bar
bar[1]
bar[2]
bar[3]
bar[1:2]
bar[c(1,3)]
bar[1,3]
bar[c(1,3)]
foo[1:2]^2
-2 * (-14.0927 - -13.374)
-2 * (-14.093 - -13.374)
install.packages(c("cols4all", "emmeans", "igraph", "lava", "reformulas", "Rmpfr", "rsconnect", "xfun", "xml2"))
install.packages(c("listenv", "promises"))
library(tidyverse)
?geom_boxplot
p <- ggplot(mpg, aes(class, hwy))
p + geom_boxplot()
# Orientation follows the discrete axis
ggplot(mpg, aes(hwy, class)) + geom_boxplot()
ggsave("~/Desktop/fig.pdf")
install.packages(c("digest", "mgcv", "pkgdown", "progressr", "purrr", "rbibutils", "reshape2", "rsconnect", "sf", "stringr", "terra", "testthat", "XML"))
install.packages(c("downlit", "ggplot2", "readr", "S7", "testthat"))
install.packages(c("downlit", "future", "gert", "ggplot2", "readr", "rsconnect", "S7", "TH.data", "xml2"))
install.packages(c("downlit", "future", "gert", "ggplot2", "readr", "rsconnect", "S7", "TH.data", "xml2"))
install.packages(c("downlit", "future", "gert", "ggplot2", "readr", "rsconnect", "S7", "TH.data", "xml2"))
foo <- rnorm(1000)
hist(foo)
install.packages(c("digest", "downlit", "fansi", "future", "gert", "ggplot2", "RcppArmadillo", "readr", "rsconnect", "S7", "selectr", "TH.data", "tinytex", "xml2"))
install.packages(c("digest", "fansi", "geojsonsf", "geometries", "insight", "jsonify", "parameters", "rapidjsonr", "RcppArmadillo", "sf", "sfheaders", "terra", "testthat", "vroom", "yaml"))
se <- function(numbers) {
stdev <- sd(numbers)
n <- length(numbers)
return(stdev/sqrt(n))
}
foo <- c(1, 2, 3)
se(foo)
se <- function(numbers) {
stdev <- sd(numbers)
n <- length(numbers)
numbers <- 0
return(stdev/sqrt(n))
}
se(foo)
testtubes <- 1:75
?sample
sample(testtubes)
testtubes
sample(testtubes)
sample(testtubes)
sample(testtubes)
sample(testtubes)
sample(testtubes)
sample(testtubes)
sample(testtubes)
sample(testtubes)
sample(testtubes)
sample(testtubes, size = 10)
sample(testtubes, replace = TRUE)
sample(testtubes) # permutation
sample(testtubes, size = 10) # random subsample
sample(testtubes, replace = TRUE) # bootstrap pseudoreplicate
runif(3)
runif(3)
runif(3)
runif(3)
runif(3)
runif(3)
runif(3)
runif(3)
runif(3)
runif(3)
runif(3)
mean(runif(3))
mean(runif(3))
mean(runif(3))
mean(runif(3))
replicate(1000, mean(runif(3)))
hist(replicate(1000, mean(runif(3))))
install.packages(c("doBy", "lme4", "performance", "xml2"))
library(ade4)
?dudi.pca
install.packages(c("broom", "future.apply", "htmltools", "httr2", "insight", "isoband", "performance", "rsconnect", "shiny", "sparsevctrs"))
install.packages(c("afex", "e1071", "emmeans", "ggeffects", "maptiles", "performance", "RcppArmadillo", "reformulas", "selectr", "stars", "tidyr", "TMB", "wk", "xfun", "zoo"))
install.packages(c("emmeans", "ggeffects", "maptiles", "performance", "RcppArmadillo", "reformulas", "selectr", "stars", "tidyr", "TMB", "wk", "xfun", "zoo"))
warnings()
setRepositories()
chooseCRANmirror)_
chooseCRANmirror()
install.packages(c("emmeans", "ggeffects", "maptiles", "performance", "RcppArmadillo", "reformulas", "selectr", "stars", "TMB", "wk", "xfun", "zoo"))
install.packages(c("e1071", "performance", "RcppArmadillo", "reformulas", "selectr", "wk"))
install.packages(c("e1071", "ggstats", "knitr", "performance", "RcppArmadillo", "reformulas", "selectr", "tidyr", "wk"))
install.packages(c("data.table", "performance"))
citation()
# Load the packages
library(tidyverse)
library(ggthemes)
library(GGally)
library(vcd)
library(ade4)
# Read in the data
meas <- read.csv("Q3.csv")
# Load packages
library(GA) # needs to be installed with install.packages("GA") first
# Define parameters for example where there are fifteen possible items
item_names <- c("Smartphone", "Bottle", "Textbook", "Laptop", "Camping Stove",
"Notebook", "Sleeping Bag", "Headphones", "USB Drive", "Binoculars",
"Camping Tent", "Jacket", "Hiking Boots", "Coursebook", "Tablet")
weights <- c(2, 3, 4, 5, 9, 3, 7, 2, 1, 6, 8, 5, 7, 9, 4)  # Weights of the items
values <- c(3, 4, 8, 8, 10, 2, 5, 2, 1, 7, 9, 5, 8, 9, 3)  # Values of the items
knapsack_capacity <- 20                                    # Maximum weight
# Define "fitness function"
# The "fitness" is the total value of the items added to the knapsack
# unless they weigh too much, in which case the knapsack will break, so "fitness" is zero
fitness_function <- function(items) {
total_weight <- sum(items * weights)
total_value <- sum(items * values)
if (total_weight <= knapsack_capacity) {
return(total_value)
} else {
return(0)
}
}
# Set up and run the genetic algorithm
ga_results <- ga(
type = "binary",                     # 'binary' because each item is either included or not
fitness = fitness_function,          # Fitness function defined earlier
nBits = length(weights),             # Number of bits (i.e., how many items, like "genes")
popSize = 500,                       # Population size
pcrossover = 0.5,                    # Crossover chance
pmutation = 0.05,                    # Mutation chance
maxiter = 200                        # Maximum number of iterations
)
# View the results
plot(ga_results)
install.packages(c("GA", "gert", "later", "lifecycle", "parallelly", "performance", "proxy", "reformulas"))
install.packages(c("later", "parallelly", "performance", "proxy", "reformulas"))
install.packages(c("forecast", "GA", "gert", "Hmisc", "later", "lifecycle", "parallelly", "performance", "purrr", "Rcpp", "reformulas", "rlang", "testthat", "tibble", "tseries"))
install.packages(c("gert", "lwgeom", "performance", "terra"))
install.packages(c("blob", "clock", "lmerTest", "lwgeom", "performance", "sf"))
install.packages("performance")
install.packages(c("glmmTMB", "performance", "shinyjs", "snowflakeauth"))
install.packages(c("future", "ggformula", "glmmTMB", "performance", "rappdirs", "renv", "rstudioapi", "segmented", "shinyjs", "snowflakeauth", "stringdist", "survival", "vctrs", "xfun", "xml2"))
citation()
install.packages(c("cpp11", "ggiraph", "performance", "rbibutils", "rnaturalearth", "rosm"))
install.packages(c("performance", "rbibutils", "rosm"))
citation()
log(2)/4.5
log(0.5+1)/0.1540327
log10(2)/4.5
log10(0.5+1)/0.1540327
4.5/log(2)
log10(0.5+1)/6.492128
install.packages(c("broom", "bslib", "data.table", "gargle", "HRW", "insight", "performance", "plotly", "Rdpack", "renv", "sparsevctrs", "timeDate", "uuid", "vctrs", "vroom"))
help(distributions)
?binom.test()
binom.test(x = 546, n = 1000)
lambda <- log(2) / 4.5
log(0.5+1)/lambda
0.89991 - 0.0001 * 0.89991
install.packages(c("base64enc", "car", "carData", "checkmate", "dplyr", "foreign", "gargle", "ggiraph", "ggplot2", "globals", "insight", "lubridate", "performance", "pkgload", "reformulas", "segmented", "timechange", "viridisLite"))
install.packages(c("cluster", "ggiraph", "insight", "lubridate", "performance", "permute", "Rdpack", "viridisLite"))
citation()
?rnorm
citation()
library(ade4)
citattion("ade4")
citation("ade4")
library(ggplot2)
?geom_point
ggplot(mtcars, aes(wt, mpg)) +
geom_point(shape = 21, colour = "black", fill = "white", size = 5, stroke = 5)
install.packages(c("dtplyr", "gdtools", "gmp", "lattice", "Rdpack", "XML"))
setwd("~/Documents/Teaching/UNB Courses/2025-2026/Winter 2026/Experimental Design/Tutorials/Tutorial 5/Data")
d <- read.csv("Data/SSRI2.csv")
d <- read.csv("SSRI2.csv")
d$Type <- factor(d$Type,
levels = c("brandname", "generic"),
labels = c("Brand-name", "Generic"))
d$SSRI <- factor(d$SSRI)
replications(Ki ~ Type/SSRI, data = d)
ggplot(data = d, aes(x = SSRI, y = Ki)) +
facet_wrap(~ Type) +
geom_boxplot(outliers = FALSE) +
geom_jitter(height = 0, width = 0.1, alpha = 0.3) +
theme_few() +
labs(y = expression(italic(K[i])*" (nM)"))
library(effectsize)
library(emmeans)
library(ggplot2)
library(ggthemes)
library(GAD)
library(HH)
library(multcomp)
library(multcompView)
ggplot(data = d, aes(x = SSRI, y = Ki)) +
facet_wrap(~ Type) +
geom_boxplot(outliers = FALSE) +
geom_jitter(height = 0, width = 0.1, alpha = 0.3) +
theme_few() +
labs(y = expression(italic(K[i])*" (nM)"))
replications(Ki ~ Type/SSRI, data = d)
ggplot(data = d, aes(x = SSRI, y = Ki)) +
facet_wrap(~ Type) +
geom_boxplot(outliers = FALSE) +
geom_jitter(height = 0, width = 0.1, alpha = 0.3) +
theme_few() +
labs(y = expression(italic(K[i])*" (nM)"))
t <- as.fixed(d$Type)
s <- as.random(d$SSRI)
SSRI.lm <- lm(Ki ~ t + s %in% t, data = d)
(SSRI.tab <- gad(SSRI.lm, quasi.f = TRUE))
comp.var(SSRI.lm, anova.tab = SSRI.tab)
opar <- par(mfrow = c(2, 2)) # Create a 2x2 plotting grid
plot(SSRI.lm, which = 5)     # Plot residuals for each factor level
plot(SSRI.lm, which = 1)     # Plot residuals vs. fitted values
plot(SSRI.lm, which = 2)     # Plot a Q-Q plot
plot(residuals(SSRI.lm) ~ I(1:60), main="Residuals vs Exp. Unit", font.main=1, data=d)
par(opar)                    # Return to original plotting settings (i.e., a 1x1 grid)
ag <- aggregate(Ki ~ SSRI %in% Type, data = d, mean)  # Mean for each SSRI
ag2 <- aggregate(Ki ~ Type, data = d, mean)           # Mean for each Type
SD.subgrp <- sqrt((7219.9-1549.9)/15) # (subgrp MS - error MS) / num. reps per subgrp
ag2$CI <- qt(1 - 0.05/2, df = 2) * SD.subgrp/sqrt(2)
ggplot(data = ag, aes(x = Type, y = Ki)) +
geom_jitter(height = 0, width = 0.1, alpha = 0.3) +
geom_pointrange(data = ag2, aes(y = Ki, ymin = Ki-CI, ymax = Ki+CI)) +
labs(x = "Drug Type", y = expression(italic(K[i])*" (nM)")) +
theme_few()
op <- options(contrasts = c("contr.sum", "contr.poly")) # Set sum-to-zero contrasts
SSRI.aov <- aov(Ki ~ Type + Error(Type:SSRI), data = d) # Fit the model
summary(SSRI.aov)                                       # Create the ANOVA table
pf(7220/1550, df1 = 2, df2 = 56, lower.tail = FALSE)    # p-value for random effect
plot(lm(SSRI.aov))                                      # Plot the residuals
y = expression(italic(K[i])*" (nM)")) +
op <- options(contrasts = c("contr.sum", "contr.poly")) # Set sum-to-zero contrasts
SSRI.aov <- aov(Ki ~ Type + Error(Type:SSRI), data = d) # Fit the model
summary(SSRI.aov)                                       # Create the ANOVA table
pf(7220/1550, df1 = 2, df2 = 56, lower.tail = FALSE)    # p-value for random effect
plot(lm(SSRI.aov))                                      # Plot the residuals
emmeans(SSRI.aov, ~Type)                                # Show EMMs
emmip(SSRI.aov, ~Type, CIs = TRUE) +                    # Plot the effect
labs(x = "Drug Type",
y = expression(italic(K[i])*" (nM)")) +
theme_few()
options(op)                                             # Reset contrasts
